const mongoose = require('mongoose');

const UserSchema  = mongoose.Schema({
	username: String,
	password: String, 
  email: {type: String, default: ''},
  createTime: {type: Date, default: Date.now},
	lastAccess: {type: Date, default: null},
	visits: {type: Number, default: 0},
	level: {type: Number, default: 0}
});

const ProjectSchema  = mongoose.Schema({
  name: String, 
  username: String,
  description: {type: String, default: ''},
  createTime: {type: Date, default: Date.now},
  updateTime: {type: Date, default: Date.now},
  share: {type: Boolean, default: true},
  data: {type: Array, default: []},
  layout: {type: Array, default: []},
  status: {type: Number, default: 0}
});
/*
  data: [
    {
      colId: '',
      key: '',
      describe: '',
      name: '',
      option: {}
    }
  ],
  layout: [
    {
      data: [{id: 'v1', col: '6'}, {id: 'v2', col: '6'}]
    }
  ]
*/

var User = mongoose.model('User', UserSchema);
var Project = mongoose.model('Project', ProjectSchema);

module.exports = {
  'User': User,
  'Project': Project
}
